<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
    var t = async_test('Cross origin but asynchronous doc.written scripts are not blocked');
    var src = 'http://localhost:8000/loading/resources/js-loaded.js?async-third-party-script';
    var jsLoaded = false;
    var loadSuccess = false;
    if (window.internals) {
        internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrameOnSlowConnections(true);
        internals.setNetworkConnectionInfoOverride(true, 'cellular2g', '4g', 100, 2.0);
        internals.evictAllResources();

        window.addEventListener('beforeunload', function() {
            internals.clearNetworkConnectionInfoOverride();
            internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrameOnSlowConnections(false);
        }, false);
    }
    document.write('<scr' + 'ipt src="' + src + '"  onload="loadSuccess=true" async></scr' + 'ipt>');
</script>
<script>
    window.addEventListener("load", t.step_func(function() {
        assert_true(loadSuccess, "Script loaded successfully");
        assert_true(jsLoaded, "Cross origin but asynchronous doc.written scripts are not blocked");
        t.done();
    }));
</script>
